<#-- @ftlvariable name="roleId" type="java.lang.String" -->
<#include "/_inc/_layout.ftl">
<@header/>
<#assign grid_url=html.urls("/auth/urmap/roleungrid?roleId=${roleId}")>
<#assign save_url=html.urls("/auth/urmap/rolesave?roleId=${roleId}")>
<div class="jxpanel winpanel" data-fit="true">
    <div id="gridtoolbar">
        <form id="gridform" class="jxform jxlayout-form">
            <table>
                <tr>
                    <td>
                        <input class="form-control w-300px" name="name" placeholder="请输入姓名/账号关键字">
                    </td>
                    <td>
                        <button class="btn btn-primary ml-5" type="submit">
                            <i class="fa fa-search"></i> 查询
                        </button>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <table id="grid" class="jxgrid" data-options="
        url: '${grid_url}',onDblClickRow: jx.auth.onUserGridDblClickRow,
        form: '#gridform',toolbar: '#gridtoolbar'">
        <thead>
            <tr>
                <th data-options="field: 'ck',checkbox:true"></th>
                <th data-options="title: '姓名', field: 'name', width: 100, align: 'center'"></th>
                <th data-options="title: '账号', field: 'account', width: 200, sortable: true, align: 'center'"></th>
                <th data-options="title: '部门', field: 'departmentName', width: 200, align: 'center'"></th>
            </tr>
        </thead>
    </table>
    <div class="panel-footer text-right">
        <button id="btnOk" class="btn btn-primary" type="button" data-url="${save_url}">
            <i class="fa fa-save"></i> 添加用户
        </button>
        <button class="btn btn-default" type="button" onclick="jx.closeDialog()">
            <i class="fa fa-sign-in"></i> 取消
        </button>
    </div>
</div>
<@footer>
<script>
    $('#btnOk').click(function () {
        var gridInstance = $('#grid').jxgrid();
        if (!gridInstance.hasCheckedRow()) return;
        var url = $(this).data('url');
        var ids = gridInstance.getCheckedRowIds();
        jx.ajax({
            url: url,
            data: { userIds: ids.join() },
            maskMsg: '正在保存,请稍等...',
            success: function (result) {
                pwin.reloadGridData();
                jx.closeDialog();
                top.jx.toastr.success('保存成功');
            }
        });
    });
</script>
</@footer>